﻿<%@ Page Title="Admin Panel" Language="C#" MasterPageFile="~/Site.Master"
     AutoEventWireup="true" CodeBehind="AdminPannel.aspx.cs" Inherits="ChatASP.AdminPannel" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager runat="server" />

    <asp:Button ID="GetUsers_Button" runat="server" Text="Users" OnClick="GetUsers" />
    <asp:Button ID="GetChannels_Button" runat="server" Text="Channels" onclick="GetChannels"/>
    <asp:Button ID="GetMessages_Button" runat="server" Text="Messages" onclick="GetMessages" />
    <br />
    <asp:Label ID="FilterLabel" runat="server" Text="Channel.............Sender..............Reciever" Visible="false"/><br />
    <asp:TextBox ID="ChannelBox" runat="server" Visible="false" Width="75px" />
    <asp:TextBox ID="SenderBox" runat="server" Visible="false" Width="75px" />
    <asp:TextBox ID="RecieverBox" runat="server" Visible="false" Width="75px" />

    <asp:UpdatePanel ID="UsersUpdate" runat="server">
        <ContentTemplate>
            
            <asp:ListView ID="UsersList" runat="server" Visible="false" 
                ItemPlaceholderID="ItemPlaceHolder"
                onitemediting="UsersList_ItemEditing"
                oniteminserting="UsersList_ItemInserting" 
                onitemdeleting="UsersList_ItemDeleting" 
                onitemupdating="UsersList_ItemUpdating"
                InsertItemPosition="LastItem">
                <LayoutTemplate>
                    <table>
                        <tr>
                            <th>
                                Username
                            </th>
                            <th>
                                Password
                            </th>
                            <th>
                                First Name
                            </th>
                            <th>
                                Last Name
                            </th>
                            <th>
                                Registration Date
                            </th>
                            <th>
                                Administrator
                            </th>
                            <th>
                                Last activity
                            </th>
                        </tr>
                        <asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <asp:Label ID="Label1" Text='<%# Eval("UserName") %>' runat="server" />
                            <asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' Visible="false" />
                        </td>
                        <td>
                            <asp:Label ID="Label2" Text='<%# Eval("Password") %>' runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="Label4" Text='<%# Eval("FirstName") %>' runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="Label5" Text='<%# Eval("LastName") %>' runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="Label6" Text='<%# Eval("RegistrationDate") %>' runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="Label7" Text='<%# Eval("Administrator") %>' runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="Label8" Text='<%# Eval("LastActivity") %>' runat="server" />
                        </td>
                        <td>
                            <asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit"/>
                        </td>
                        <td>
                            <asp:LinkButton ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete"/>
                        </td>
                    </tr>
                </ItemTemplate>
                <InsertItemTemplate>
                    <tr>
                        <td>
                            <asp:TextBox runat="server" ID="NewUsernameTextBox" Width="100px" />
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="NewPasswordTextBox" Width="100px" />
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="NewFirstNameTextBox" Width="100px" />
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="NewLastNameTextBox" Width="100px" />
                        </td>
                        <td>
                            <asp:CheckBox ID="NewAdminCheckBox" runat="server" Text="Admin" />
                        </td>
                        <td>
                            <asp:LinkButton ID="UpdateButton" runat="server" Text="Insert" CommandName="Insert"/>
                        </td>
                    </tr>
                </InsertItemTemplate>
                <EditItemTemplate>
                    <tr>
                        <td>
                            <asp:TextBox ID="UserNameEditLabel" Text='<%# Eval("UserName") %>' runat="server" Width="100px" />
                            <asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' Visible="false" />
                        </td>
                        <td>
                            <asp:TextBox ID="UserPasswordEditLabel" Text='<%# Eval("Password") %>' runat="server" Width="100px" />
                        </td>
                        <td>
                            <asp:TextBox ID="UserFirstNameEditLabel" Text='<%# Eval("FirstName") %>' runat="server" Width="100px" />
                        </td>
                        <td>
                            <asp:TextBox ID="UserLastNameEditLabel" Text='<%# Eval("LastName") %>' runat="server" Width="100px" />
                        </td>
                        <td>
                            <asp:CheckBox ID="UserAdminCheckBox" runat="server" Text="Admin" Checked='<%# Eval("Administrator") %>' />
                        </td>
                        <td>
                            <asp:LinkButton ID="UpdateButton" Text="Update" CommandName="Update" runat="server"/>
                        </td>
                    </tr>
                </EditItemTemplate>
            </asp:ListView>

            <asp:ListView ID="ChannelsList" runat="server" Visible="false" 
                ItemPlaceholderID="ItemPlaceHolder"
                onitemdeleting="ChannelsList_ItemDeleting" 
                onitemediting="ChannelsList_ItemEditing" 
                oniteminserting="ChannelsList_ItemInserting" 
                onitemupdating="ChannelsList_ItemUpdating" 
                InsertItemPosition="LastItem">
                <LayoutTemplate>
                    <table>
                        <tr>
                            <th>
                                Channel Name
                            </th>
                            <th>
                                Description
                            </th>
                        </tr>
                        <asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <asp:Label ID="Label9" runat="server" Text='<%# Eval("ChannelName") %>' />
                            <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ChannelID") %>' Visible="false" />
                        </td>
                        <td>
                            <asp:Label ID="Label10" Text='<%# Eval("Description") %>' runat="server" />
                        </td>
                        <td>
                            <asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit"/>
                        </td>
                        <td>
                            <asp:LinkButton ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete"/>
                        </td>
                    </tr>
                </ItemTemplate>
                <InsertItemTemplate>
                    <tr>
                        <td>
                            <asp:TextBox runat="server" ID="NewChannelTextBox" Width="100px" />
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="NewDescriptionTextBox" Width="100px" />
                        </td>
                        <td>
                            <asp:LinkButton ID="UpdateButton" runat="server" Text="Insert" CommandName="Insert"/>
                        </td>
                    </tr>
                </InsertItemTemplate>
                <EditItemTemplate>
                    <tr>
                        <td>
                            <asp:TextBox ID="ChannelNameEditLabel" Text='<%# Eval("ChannelName") %>' runat="server" Width="100px" />
                            <asp:Label ID="ChannelIDLabel" runat="server" Text='<%# Eval("ChannelID") %>' Visible="false" />
                        </td>
                        <td>
                            <asp:TextBox ID="DescriptionEditLabel" Text='<%# Eval("Description") %>' runat="server" Width="100px" />
                        </td>
                        <td>
                            <asp:LinkButton ID="UpdateButton" runat="server" Text="Update" CommandName="Update"/>
                        </td>
                    </tr>
                </EditItemTemplate>
            </asp:ListView>

            <asp:ListView ID="MessagesList" runat="server" Visible="false" ItemPlaceholderID="ItemPlaceHolder">
                <LayoutTemplate>
                    <asp:Button ID="FilterMessages_Button" runat="server" Text="Filter" OnClick="FilterMessages" />
                    <br /><asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                </LayoutTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" Text='<%# Eval("Text") %>' runat="server" /><br />
                </ItemTemplate>
            </asp:ListView>

        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
